package where2go.sctu.com.zhiyou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import where2go.sctu.com.zhiyou.MainActivity;
import where2go.sctu.com.zhiyou.R;
import where2go.sctu.com.zhiyou.utils.ShareUtils;
import where2go.sctu.com.zhiyou.view.CustomDialog;

/**
 * Created by lenovo on 2018/5/16.
 */

public class MySetingActivity extends AppCompatActivity {
    private ImageView imageView;
    private Button btnLogout;

    private CustomDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_seting);
        initView();
    }

    private void initView() {
        imageView = (ImageView) findViewById(R.id.seting);
        btnLogout = (Button) findViewById(R.id.btn_logout);
        btnLogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog = new CustomDialog(MySetingActivity.this,
                        "确定要注销登录吗?",
                        "注销",
                        "取消");
                dialog.setTitle("提示");
                dialog.show();
                dialog.setClicklistener(new CustomDialog.ClickListenerInterface() {
                    @Override
                    public void doConfirm() {
                        ShareUtils.deleShare(MySetingActivity.this, "token");
                        startActivity(new Intent(MySetingActivity.this,
                                MainActivity.class));
                    }

                    @Override
                    public void doCancel() {
                        dialog.dismiss();
                    }
                });
            }
        });
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
}
